<?php

declare(strict_types=1);

namespace app\shop\controller\admin;

use think\Request;
use think\Response;
use sheep\controller\Backend;
use app\shop\model\Share as ShareModel;

class Share extends Backend
{
    protected $model = null;

    public function initialize()
    {
        $this->model = new ShareModel();
    }

    /**
     * 查看用户分享记录
     *
     * @return Response
     */
    public function list(Request $request, $id): Response
    {
        $data = ShareModel::with(['user' => function ($query) {
            return $query->field(['id', 'nickname', 'avatar']);
        }])->where('share_id', $id)->sheepFilter()->paginate($request->param('list_rows', 8));

        return success('', $data);
    }
}
